Apache Wink : 5.5 Spring Integration
This page last changed on Oct 12, 2009 by bluk.
Spring IntegrationApache Wink provides an additional module deployed as an external jar in order to provide Spring integration. The Spring integration provides the following features:
Spring RegistrationSpring makes it convenient to register resources and providers as spring beans. <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:META-INF/server/winkCoreContext-server.xml classpath:mycontext.xml </param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> Registering Resources and ProvidersApache Wink provides the org.apache.wink.spring.Registrar class in order to register resources and providers through a Spring context. The Registrar class extends the WinkApplication class and must be registered as a singleton spring bean. It is possible to define multiple registrars in the same context. All registrars are automatically collected by the runtime and registered as WinkApplication objects during the context loading. The registrar provides the following properties:
<bean class="org.apache.wink.spring.Registrar"> <property name="classes"> <set value-type="java.lang.Class"> <value>package.className</value> </set> </property> <property name="instances"> <set> <ref bean="resources.resource1" /> <ref bean="resources.resource2" /> <ref bean="providers.provider1" /> </set> </property> </bean> Custom Properties File DefinitionApache Wink provides a set of customizable properties. When working with Spring, the user should redefine the custom properties file using the Spring context: <bean id="customPropertiesFactory" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="locations"> <list> <value>WEB-INF/configuration.properties</value> </list> </property> </bean> <bean id="customConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="ignoreUnresolvablePlaceholders" value="true" /> <property name="order" value="1" /> <property name="propertiesArray"> <list> <props> <prop key="wink.propertiesFactory">customPropertiesFactory</prop> </props> </list> </property> </bean>
Customizing Media-Type MappingsApache Wink provides the ability to customize the Media-Type mappings using Spring context.
<bean id="custom.MediaTypeMapper" class="org.apache.wink.server.internal.MediaTypeMapper"> <property name="mappings"> <list> <map> <entry key="userAgentStartsWith" value="Mozilla/" /> <entry key="resultMediaType"> <util:constant static-field=" javax.ws.rs.core.MediaType.ATOM" /> </entry> <entry key="typeToSend"> <util:constant static-field="javax.ws.rs.core.MediaType.TEXT_XML" /> </entry> </map> </list> </property> </bean> <bean id="customConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="ignoreUnresolvablePlaceholders" value="true" /> <property name="order" value="1" /> <property name="propertiesArray"> <list> <props> <prop key="wink.MediaTypeMapper">custom.MediaTypeMapper</prop> </props> </list> </property> </bean>
Customizing Alternative ShortcutsApache Wink provides the ability to customize the Alternative Shortcuts in one of two ways.
External Properties FileThe shortcuts are defined in a properties file. The shortcuts properties file is loaded in the same way that the configuration properties file is loaded. <bean id="custom.Shortcuts" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="locations"> <list> <value>WEB-INF/shortcuts</value> </list> </property> </bean> <bean id="customConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="ignoreUnresolvablePlaceholders" value="true" /> <property name="order" value="1" /> <property name="propertiesArray"> <list> <props> <prop key="wink.alternateShortcutsMap">custom.Shortcuts</prop> </props> </list> </property> </bean> Spring Context FileDefines the map of the shortcuts in the Spring context. |
Document generated by Confluence on Nov 11, 2009 06:57 |